package com.example.board.controller;


import com.example.board.common.R;
import com.example.board.pojo.vo.IndustryShareDetailVo;
import com.example.board.pojo.vo.IndustryShareVo;
import com.example.board.service.OperatorAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/")
@Api(tags = "本部业务员分析", value = "本部业务员分析")
@RequiredArgsConstructor
public class OperatorAnalysisController {

    private final OperatorAnalysisService operatorAnalysisService;

    @ApiOperation("各行业合计成交")
    @PostMapping(value = "/local-salesman-board/total")
    public R getAllDeal() {

        Map<String ,Object> map = new HashMap<>();
        map.put("total", Integer.parseInt(operatorAnalysisService.getAllDetail()));
        return R.ok(map);
    }


    @ApiOperation("最高占比行业")
    @PostMapping(value = "/local-salesman-board/highest-industry")
    public R getIndustryShareMax(String province,String region) {
        List<IndustryShareVo> industryShareMax = operatorAnalysisService.getIndustryShareMax(province, region);
        Map<String,Object> map = new HashMap<>();
        map.put("chartsData",industryShareMax);
        return R.ok(map);
    }

    @ApiOperation("成交客户类别分析")
    @PostMapping(value = "/local-salesman-board/customer-type")
    public R getIndustryShareDetail(String province,String region) {

        List<IndustryShareDetailVo> industryShareDetail = operatorAnalysisService.getIndustryShareDetail(province, region);
        Map<String,Object> map = new HashMap<>();
        map.put("chartsData",industryShareDetail);
        return R.ok(map);
    }


}
